<p>
    <?= $this->Html->link("&laquo; Nazad na listu", "/cenovnici", array('escape'=>false)) ?>
</p>

<?= $this->Form->create('ProductPrice', array('url'=>'/cenovnici/sacuvaj', 'class'=>'entity-form')) ?>
    
    <?= $this->Form->submit('Sačuvaj', array('div'=>false)) ?>
    <?= $this->Form->label('date', 'Datum:', array('class'=>'auto inline')) ?>
    <?= $this->Form->text('date', array('class'=>'datepicker', 'value'=>$date))?>
    
    <table class="entity-table">
        <? foreach($products as $type=>$rows): ?>
        <tr>
            <th class="section" align="center" colspan="2"><?= ucfirst($type) ?></th>
        </tr>
        <tr>
            <th>Proizvod</th>
            <th align="right">Cena</th>
        </tr>
            <? foreach($rows as $product): ?>
            <? 
                $product_id = $product['Product']['id'];
                $price = @$data[$product_id]['ProductPrice']['price'];
                $id = (int)@$data[$product_id]['ProductPrice']['id'];
            ?>
            <tr>
                <td><?= $product['Product']['name'] ?></td>
                <td align="right">
                    <?= $this->Form->hidden("$product_id.ProductPrice.id", array('value'=>$id)) ?>
                    <?= $this->Form->hidden("$product_id.ProductPrice.product_id", array('value'=>$product_id)) ?>
                    <?= $this->Form->text("$product_id.ProductPrice.price", array('class'=>'price text-right', 'value'=>$price)) ?>
                </td>
            </tr>
            <? endforeach; ?>
        <? endforeach; ?>
    </table>

    <?= $this->Form->submit('Sačuvaj', array('div'=>false)) ?>
<?= $this->Form->end() ?>